﻿@model DLMemberPointMS.Entity.ViewModel.MemCardSEditViewModel
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/layui/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <title>挂失/锁定</title>
    <style>

    </style>
</head>
<body>
    <fieldset class="layui-elem-field layui-field-title">
        <legend>挂失/锁定</legend>
    </fieldset>
    @using (Html.BeginForm("", "", FormMethod.Post, new { @class = "layui-form" }))
    {
        <div class="layui-input-inline">
            <label class="layui-form-label">会员卡号</label>
            <div class="layui-input-inline">
                <label class="layui-form-label" id="MC_CardID" >@Html.DisplayFor(model => model.MC_CardID, new { htmlAttributes = new {  @class = "layui-input ", lay_verify = "required" } })</label>
                
            </div>
        </div><br><br>
        <div class="layui-input-inline">
            <label class="layui-form-label">卡片状态</label>
            <div class="layui-input-inline">
                @Html.DropDownList("MC_State", (ViewData["state"]) as IEnumerable<SelectListItem>, new { id = "MC_State", lay_verify = "required|state" })
            </div>
        </div><br /><br>
        <div class="layui-input-inline">
            <div class="layui-btn-container">
                <label class="layui-form-label"></label>
                <button type="button" class="layui-btn layui-btn-sm" id="submit" lay-submit lay-filter="submitform"><i class="layui-icon">&#xe654;确定</i></button>
                <button type="button" class="layui-btn layui-btn-sm" id="close"><i class="layui-icon">关闭</i></button>
            </div>
        </div>
    }


    <script>

        layui.use(['layer', 'form', 'laydate'], function () {
            var layer = layui.layer,
                form = layui.form,
                laydate = layui.laydate

            //表单验证
            form.verify({
                state: function (value, item) {
                    //value：表单的值、item：表单的DOM对象
                    if (value == 0) {
                        return '请选择卡片状态！';
                    }
                }
            });

            //提交按钮
            form.on('submit(submitform)', function (data) {
                var index = parent.layer.getFrameIndex(window.name); //得到当前iframe层的索引
                var formData = $('.layui-form').serializeArray();
                var cardId = $('#MC_CardID').text().trim();
                var state = $('#MC_State').val();
                $.ajax({
                    url: '/Member/ChangeState',
                    type: 'post',
                    data: {"MC_CardID":cardId,"MC_State":state},
                    success: function (data) {
                        if (data.code == 0) {
                            parent.layer.msg(data.msg, { icon: 1 });
                            parent.layer.close(index); //再执行关闭
                        } else {
                            parent.layer.msg(data.msg, { icon: 5 });
                            parent.layer.close(index); //再执行关闭
                        }
                    },
                    error: function (data) {
                        parent.layer.msg(data.msg, { icon: 2 });
                        parent.layer.close(index); //再执行关闭
                    }
                })
            })
            //关闭弹窗
            $('#close').click(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })
        })
    </script>
</body>
</html>
